#include <bits/stdc++.h>

using namespace std;

const int MAXN = 1e5+10;

int d[MAXN],vb[MAXN],a[MAXN]; int p[MAXN];

void solve(){
    int n,m,l,v; cin >> n >> m >> l >> v;
    for(int i=1;i<=n;i++){
        cin >> d[i] >> vb[i] >> a[i];
    }
    
    for(int i=1;i<=m;i++){
        cin >> p[i];
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if(d[i] > p[m]) continue;
        int vm = 2 * a[i] * (p[m] - d[i]) + vb[i] * vb[i];
        if(v * v < vm) ans++;
    }
    if(ans > 0){
        cout << ans << ' ' << m-1 << '\n';
    } else {
        cout << ans << ' ' << m << '\n';
    }
    return;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int t; cin >> t;
    while(t--){
        solve();
    }
    return 0;
}